//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.restaurant.application.configsignin;

import com.google.common.base.Strings;
import com.nebutown.base.ViewSpec;
import com.nebutown.base.data.View;
import com.nebutown.base.data.ViewUpdate;
import com.nebutown.commonunits.dataface.DataModes;
import com.nebutown.commonunits.dataface.FormShell;
import com.nebutown.commonunits.dataface.definitions.PageForm;
import com.nebutown.commonunits.uidataface.UIDataFace;
import com.nebutown.generation.basicdata.StringMap;
import com.restaurant.application.configsignin.support.AbstractConfigSignIn;
import com.restaurant.application.configsignin.support.ConfigSignInData;
import java.util.List;
import java.util.Objects;

public class ConfigSignInImpl extends AbstractConfigSignIn {
    public ConfigSignInImpl() {
    }

    public ViewUpdate save(ConfigSignInData save, int[] seq) {
        FormShell formShell = this.newFormShell(save);
        boolean b = formShell.dataFailedValidation();
        if (!b) {
            this.setData(save);
        }

        return this.returnViewCall(this.buildViewCall(this.unitPosition(), "showErrorMessage", (List)null, (new StringMap()).putData("errorMessage", "设置成功")));
    }

    public View getFullView() {
        PageForm pageForm = this.newFormShell(this.getData().duplicate()).getForm();
        return ((UIDataFace)this.getSingleton(UIDataFace.class)).newUniForm(this.unitPosition(), pageForm);
    }

    public View getViewLead(ViewSpec spec) {
        return null;
    }

    private FormShell newFormShell(ConfigSignInData data) {
        FormShell formShell = new FormShell("设置/签到积分设置", 2, 3);
        formShell.source(data, DataModes.VALIDATE);
        formShell.at(0, 0, "每次签到积分").longField("signInScore", data.getSignInScore()).placeHolder("每次签到积分").setEditable(true);
        if (!Strings.isNullOrEmpty(this.getPath(CMD_SAVE, new int[0]))) {
            formShell.at(0, 1, "").buttonField(this.getPath(CMD_SAVE, new int[0]), "设置", "", true);
        }

        return formShell;
    }

    public long getSignInScore() {
        return Objects.isNull(this.getData().getSignInScore()) ? 10L : this.getData().getSignInScore();
    }
}
